//
//  HSCBannerItemView.m
//  BannerDemo
//
//  Created by 红沙尘 on 2018/12/14.
//  Copyright © 2018年 红沙尘. All rights reserved.
//

#import "HSCBannerItemView.h"
#import <UIImageView+WebCache.h>
@interface HSCBannerItemView () {
    UIImageView *imgV;
}

@end


@implementation HSCBannerItemView

- (instancetype)initWithFrame:(CGRect)frame data:(NSDictionary *)data {
    self = [super initWithFrame:frame];
    
    if (self) {
        self.data = data;
        self.clipsToBounds = YES;
        imgV = [[UIImageView alloc] initWithFrame:self.bounds];
        imgV.clipsToBounds = YES;
        imgV.layer.cornerRadius = 5;
        imgV.contentMode = UIViewContentModeScaleAspectFill;
        imgV.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
        imgV.tag = 5000;
        [imgV sd_setImageWithURL:[NSURL URLWithString:data[@"image"]]];

        [self addSubview:imgV];
    }
    
    return self;
}

- (void)show {
    CGFloat offScale = self.center.x - self.frame.size.width/2;
    CGFloat scale = 1 - 1.0/5.0*(fabs(offScale)/self.frame.size.width/2);
    scale = MAX(scale, 0.9);
    NSLog(@"scale = %f",scale);
    imgV.transform = CGAffineTransformMakeScale(scale, scale);
}

@end
